import React, { Component } from 'react';
import { Button, Input} from 'antd';

class InputCom extends Component {
    constructor(props) {
        super(props);
        this.inputField = this.props['field']
		this.state = this.setParamsData(this.props)
    }

    componentWillMount() {
	
    }

    componentDidMount() {

    }
	setParamsData(config) {
		let fetch = {}
		const { field, defaultValue } = config
		fetch[field] = defaultValue || ''
		return fetch
	}
	onInputChange(e) {
		let inputVal = e.target.value
		this.state[this.inputField] = inputVal
		this.setState({...this.state})
		console.log(inputVal, this.state)
	}
	getFetchData() {
		let data = this.state
		return data
	}

    render() {
		const { width } = this.props
        return (
             <Input value={this.state[this.inputField]} onChange={this.onInputChange.bind(this)} style={{ width }} { ...this.props }/>
        );
    }
	
}

export default InputCom;
